/*
 * Cellular Jail
 */

#include "stdafx.h"
#include <cstdlib>
using namespace std;

inline int get_dist(int* c1, int* c2, int ndims)  {
	int dist = 0;
	for(int i = 0; i < ndims; i++)
		dist += abs(c1[i] - c2[i]);

	return dist;
}
void cellular_jail_main()  {
	int ncells, ndims;
	cin >> ncells >> ndims;

	// create a 2-d array to store the each cell location
	int **cells;
	cells = new int*[ncells];
	for(int i = 0; i < ncells; i++)  {
		cells[i] = new int[ndims];  
		// input this cell location.
		for(int j = 0; j < ndims; j++) cin >> cells[i][j];
	}

	vector<int*> winners;
	for(int i = 0; i < ndims; i++)   {
		// find the max, min along this dimension;
		int max, min;
		max = min = cells[0][i];
		for(int j = 1; j < ncells; j++)  {
			if(max < cells[j][i]) max = cells[j][i];
			if(min > cells[j][i]) min = cells[j][i];
		}
		// find all elements equal to max or min
		for(int j = 0; j < ncells; j++)  {
			if(cells[j][i] == max) winners.push_back(cells[j]);
			if(cells[j][i] == min) winners.push_back(cells[j]);
		}
	}
	// iterate over winners and find max distance
	int max_dist = 0, *p1, *p2;
	for(int i = 0; i < winners.size(); i++)  {
		for(int j = i+1; j < winners.size(); j++)  {
			int dist = get_dist(winners[i], winners[j], ndims);
			if(dist > max_dist) {
				max_dist = dist;
				p1 = winners[i];
				p2 = winners[j];
			}
		}
	}
	for(int i = 0; i < ndims; i++) cout << p1[i] << " "; cout << endl;
	for(int i = 0; i < ndims; i++) cout << p2[i] << " "; cout << endl;
}